<?php 
/*
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-06-17 19:43:04 +0200 (Tue, 17 Jun 2008) $
 * $Rev: 1179 $
 * $Author: styck $
 * $Id: ajax_showpreview.php 1179 2008-06-17 17:43:04Z styck $
 */
define('ORIGINAL_PAGE', $_SERVER['PHP_SELF']);
$__auth = 'silent';
$pathadctl = realpath(dirname(__FILE__));

require_once("$pathadctl/../functions/html_includes.php");
require_once("$pathadctl/../functions/pref_functions.php");

if (!$isadmin)
	fatal_error($LN['error_noadmin']);

$prefs = load_config($db);
$uc = new urdd_client($prefs['urdd_host'], $prefs['urdd_port'], $userID);


if ($prefs['forumusername'] == '' || $prefs['forumpassword'] == '')
	$disable_urdland = 1;
else
	$disable_urdland = 0;


if ($uc->is_connected()) {
	$isconnected = 1;
	$queue_info = $uc->show('queue');
	$jobs_info = $uc->show('jobs');
	$threads_info = $uc->show('threads');
	$servers_info = $uc->show('servers');
	$load_info = $uc->show('load');
	$uptime_info = $uc->uptime();
	unset($jobs_info[0]);
	unset($load_info[0]);
	unset($servers_info[0]);
	unset($threads_info[0]);
	unset($queue_info[0]);
} else {
	$isconnected = 0;
	$queue_info = '';
	$jobs_info = '';
	$load_info = array (1=>'', 2=>'', 3=>'');
	$threads_info = '';
	$servers_info = '';
	$uptime_info = '';
}


$challenge = set_challenge();
$smarty->assign('title',            $LN['control_title']);
$smarty->assign('isconnected',      $isconnected);
$smarty->assign('disable_urdland',  $disable_urdland);
$smarty->assign('challenge',        $challenge);
$smarty->assign('queue_info',       $queue_info);
$smarty->assign('uptime_info',      $uptime_info);
$smarty->assign('threads_info',     $threads_info);
$smarty->assign('jobs_info',        $jobs_info);
$smarty->assign('load_info',        $load_info);
$smarty->assign('servers_info',     $servers_info);
$smarty->assign('referrer',         'action');
$smarty->assign('menu',             generate_menu($LN));
$smarty->display('ajax_admincontrol.tpl');

